package xjtu.zd.server.staff.chapter.impl;


import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import xjtu.zd.server.common.Classification;
import xjtu.zd.server.common.PageParam;
import xjtu.zd.server.common.Utils;
import xjtu.zd.server.common.page.QueryAction;
import xjtu.zd.server.staff.chapter.*;
import xjtu.zd.server.staff.chapter.dao.ChapterDao;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ChapterServiceImpl implements ChapterService {

    @Resource
    private ChapterDao chapterDao;

    @Override
    public Map<String, Object> searchChapterPage(SearchDto dto){
        Map<String, Object> page = Utils.getPage(dto, ()->chapterDao.findChapterList(dto));
        return page;
    }

    @Override
    public void HandleChapter(EditDto dto){
        chapterDao.updChapter(dto);
    }

    @Override
    public ChapterDto getChapterfilename(String ch_id) {
        ChapterDto dto = new ChapterDto();
        dto.setTxt(chapterDao.findChapterfilename(ch_id));
        dto.setB_name(chapterDao.findChapterbookname(ch_id));
        return dto;
    }

    @Override
    public List<String> getLevel(){
        return chapterDao.findLevel();
    }

    @Override
    public List<Classification> getClassification(){
        return chapterDao.findClass();
    }
}
